package org.jwcloud.project.module.zx.jindu.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.jwcloud.project.module.zx.baseManager.service.repository.MatBaseManagerRepository;
import org.jwcloud.project.module.zx.common.FmtUtil;
import org.jwcloud.project.module.zx.common.Resp;
import org.jwcloud.project.module.zx.common.repository.RptCommonRepository;
import org.jwcloud.project.module.zx.common.service.RptUtService;
import org.jwcloud.project.module.zx.jindu.service.repository.MatJinduRepository;
import org.jwcloud.project.module.zx.zhuanxiang.service.repository.MatZhuanxiangRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageHelper;
import com.jw.mid.mm.comm.common.controller.BaseController;
import com.jw.mid.mm.comm.common.controller.CrudController;
import com.jw.mid.mm.comm.common.json.Response;
import com.jw.mid.mm.comm.common.pagination.ListBounds;
import com.jw.mid.mm.comm.common.pagination.ListSlice;
import com.jw.mid.mm.comm.common.pagination.PageListSlice;
import com.jw.mid.mm.comm.common.pagination.Pagination;
import com.jw.mid.mm.comm.common.service.CrudService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
/**

 
;
 * @author song
 *
 */
//@Api(value = "API - Controlle",
//description = "进度管理", tags = "jindu")
//@RestController
//@Transactional
//@RequestMapping("/rest/mat/jindu")
public class MatJinduController extends BaseController{
	
	@Autowired
	public RptCommonRepository rptCommonRepository;
	
	@Autowired
	public MatJinduRepository matJinduRepository;
	
	@Autowired
    public RptUtService rptUtService;
	
	@RequestMapping("/sysTip")
	public ModelAndView sysTip(String param, ModelAndView model) {
		model.setViewName("test/jindu/sysTip.html");
		return model;
	}
	@RequestMapping("/sysWarn")
	public ModelAndView sysWarn(String param, ModelAndView model) {
		model.setViewName("test/jindu/sysWarn.html");
		return model;
	}
	
	@GetMapping("querySysTipList")
    @ApiOperation(value = "系统提醒", notes = "")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "sq_type", value = "申请类型 sq yfk js", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "work_type_name", value = "工作名称 传汉字", required = false, dataType = "string", paramType = "query"),
    	
    	@ApiImplicitParam(name = "warn_type", value = "tip first_warn second_warn", required = true, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "done_state", value = "完成情况 0未完成 1按时完成 2超时完成", required = true, dataType = "string", paramType = "query"),
    	
    })
    public Resp queryItemList(
    		@RequestParam(required = false) Map<String,String> param
    		){
		
		String flag = FmtUtil.nullRes(param
		, "warn_type", "warn_type");
		if(!StringUtils.isEmpty(flag)) 
			return Resp.error(flag);
		
		return Resp.success(this.rptUtService.pageBuild(
				() -> this.matJinduRepository.querySysTipList(param), param));
    }
	
	
	@PostMapping("doDuban_byWarn")
    @ApiOperation(value = "督办", notes = "")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "rel_view_tip_all_id", value = "1", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "rel_base_id", value = "2", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "process_code", value = "3", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "tip_type", value = "4", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "sq_type", value = "5", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "top_db_content", value = "6", required = false, dataType = "string", paramType = "query"),
    })
    public Resp doDuban_byWarn(
    		@RequestBody(required = false) Map<String, Object> param
    		){
//		String flag = FmtUtil.nullRes(param
//				, "process_log_id", "process_log_id"
//				, "get_name", "取件人姓名"
//				, "get_id_card", "身份证号"
//				, "get_phone", "联系电话"
//				, "get_date", "取件时间");
//		if(!StringUtils.isEmpty(flag)) 
//			return Resp.error(flag);
		
		return Resp.success(this.matJinduRepository.doDuban(param));
    }
	
}